package cn.tedu.sp04.feign.fallback;

import org.springframework.stereotype.Component;

import cn.tedu.pojo.User;
import cn.tedu.sp04.feign.UserFeignService;
import cn.tedu.web.util.JsonResult;

@Component
public class UserFeignServiceFB implements UserFeignService {

	@Override
	public JsonResult<User> getUser(Integer userId) {
		//40%的概率返回缓存数据
		if(Math.random()<0.4) {
			return JsonResult.ok(new User(99,"asdfgh","123456"));
		}
		return JsonResult.err("获取用户信息失败");
	}

	@Override
	public JsonResult addScore(Integer userId, Integer score) {
		return JsonResult.err("为用户增加积分失败");
	}

}
